﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;

namespace Web.admin.InnerManage.Participants
{
    public partial class GroupMember : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["GroupId"]))
                {
                    RpListBin(Request.QueryString["GroupId"]);
                }
            }
        }

        /// <summary>
        /// 添加学生事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddStudent_Click(object sender, EventArgs e)
        {
            Response.Redirect("addStudent.aspx?OPERATION=AddGroStudent&GroupId=" + Request.QueryString["GroupId"]);
        }

        /// <summary>
        /// 通过小组id来绑定repeater
        /// </summary>
        /// <param name="GroupId">小组id</param>
        protected void RpListBin(string GroupId)
        {
            BLL.ParticipantService participantservice = new BLL.ParticipantService();
            RpList.DataSource = participantservice.GetGroupParticipants(GroupId);
            RpList.DataBind();
        }

        /// <summary>
        /// repeater操作事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Rp_Event(object sender, RepeaterCommandEventArgs e)
        {
            BLL.ParticipantService participantservice = new BLL.ParticipantService();
            string parId = ((HiddenField)e.Item.FindControl("Hf_id")).Value;
            switch (e.CommandName)
            {
                case "par_Del":
                     BoParticipants ParticipantsModel = new BoParticipants();
                    ParticipantsModel.PAR_ID = parId;
                    participantservice.RemoveParticipant(ParticipantsModel);
                    break;
            }
            RpListBin(Request.QueryString["GroupId"]);
        }
    }
}